package com.heima.estatemanagement.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.heima.estatemanagement.domain.TbParkingUse;
import com.heima.estatemanagement.service.TbParkingUseService;
import com.heima.estatemanagement.mapper.TbParkingUseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.thymeleaf.util.StringUtils;
import tk.mybatis.mapper.util.StringUtil;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 86191
 * @description 针对表【tb_parking_use(车位使用表)】的数据库操作Service实现
 * @createDate 2023-02-03 14:24:26
 */
@Service
public class TbParkingUseServiceImpl extends ServiceImpl<TbParkingUseMapper, TbParkingUse>
        implements TbParkingUseService{

    @Autowired
    private TbParkingUseMapper parkingUseMapper;

    @Override
    public Page<TbParkingUse> search(Map searchMap) {
        Map map=new HashMap();
//        if ((Integer)searchMap.get("pageNum")!=null){
//            pageNum=(int)searchMap.get("pageNum");

//        }
//        if ((Integer)searchMap.get("pageSize")!=null){
//            pageSize=(int)searchMap.get("pageSize");
//        }
        map.put("pageSize",searchMap.get("pageSize"));
        map.put("pageNum",searchMap.get("pageNum"));
        if(StringUtil.isNotEmpty((String) searchMap.get("LAY_demorange_s"))){
            map.put("LAY_demorange_s",searchMap.get("LAY_demorange_s"));
        }

        if(StringUtil.isNotEmpty((String) searchMap.get("LAY_demorange_e"))){
            map.put("LAY_demorange_e",searchMap.get("LAY_demorange_e"));
        }

        if (!StringUtils.isEmpty((String) searchMap.get("name"))){
            map.put("name",searchMap.get("name"));
        }

        if (!StringUtils.isEmpty((String) searchMap.get("community_id"))){
            map.put("community_id",searchMap.get("community_id"));
        }
        System.out.println(searchMap.get("community_id"));

        if (!StringUtils.isEmpty((String)searchMap.get("status"))){
            map.put("status",searchMap.get("status"));
        }

        if (!StringUtils.isEmpty((String)searchMap.get("switch"))){
            map.put("switch",searchMap.get("switch"));
        }

        Page<TbParkingUse> search = parkingUseMapper.search(map);
        search.setTotal(parkingUseMapper.parkingCount(map));
        return search;
    }

    @Override
    public int parkingCount(Map map) {
        return parkingUseMapper.parkingCount(map);
    }

    @Override
    public List<TbParkingUse> selectAll() {
        return parkingUseMapper.selectAll();
    }


    @Override
    public int add(TbParkingUse parkingUse) {
        return parkingUseMapper.add(parkingUse);
    }


    @Override
    public TbParkingUse findById(Integer id) {
        return parkingUseMapper.findById(id);
    }

    @Override
    public int update(TbParkingUse parkingUse) {
        return 0;
    }
}




